from django_redis import get_redis_connection


class MyRedis:
    def __init__(self):
        self.redis=get_redis_connection()
    def setcode(self,phone,code):
        return self.redis.setex(phone,60*3,code)

    def getcode(self,phone):
        val=self.redis.get(phone)
        if val:
            return val.decode('utf-8')
        else:
            return None
redis_tool=MyRedis()